/**
 * Created by dukes on 2016/3/2.
 */
class GuildMemberItemRender extends eui.ItemRenderer {
    public constructor() {
        super();
        this.skinName = "skins.scene.elements.GuildMemberitemSkin";
        this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTouched, this);
    }

    private onTouched(evt:egret.TouchEvent){
        if( Model.me.id == this.data.userId) return;
        GuildPopPanel.getInstance().show(this.data,evt.stageX,evt.stageY);
    }

    public dataChanged(){
        super.dataChanged();
        this.lab_name.text = LimitStringLen(this.data.userName);
        this.lab_level.text = this.data.petGradeSum+"";
        this.lab_cnt.text = GetNumString(this.data.totalContribution,false,true);
        this.img_mark.visible = this.data.role == 1;
    }

    private lab_name:eui.Label;
    private lab_level:eui.Label;
    private lab_cnt:eui.Label;
    private img_mark:eui.Image;
    public partAdded(name:string, instance:any){
        super.partAdded(name,instance);
        if( name == "lab_name"){
            this.lab_name = instance;
        }else if( name == "lab_level"){
            this.lab_level = instance;
        }else if( name == "lab_cnt"){
            this.lab_cnt = instance;
        }else if( name == "img_mark"){
            this.img_mark = instance;
        }
    }
}